package com.huishu.order.fegin;

import com.huishu.commons.pojo.Result;
import com.huishu.commons.pojo.dto.FindAvailableCouponDTO;
import com.huishu.commons.pojo.dto.ReturnUserCouponDTO;
import com.huishu.commons.pojo.dto.SendRepurchaseDTO;
import com.huishu.commons.pojo.dto.UseCouponDTO;
import com.huishu.commons.pojo.vo.CouponVO;
import com.huishu.order.fegin.fallback.CouponFeignClientFallBack;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;
import java.util.Map;

/**
 * @ClassName：CouponFeignClient
 * @Author: ljj
 * @Date: 2023/4/11 15:01
 * @Description:
 */
@FeignClient(name = "coupon-server", path = "/coupon", fallbackFactory = CouponFeignClientFallBack.class)
public interface CouponFeignClient {

    @PostMapping("/coupon/find-available-coupon")
    Result<List<CouponVO>> findAvailableCoupon(@RequestBody FindAvailableCouponDTO findAvailableCouponDTO);

    @PostMapping("/coupon/find-coupon-byUserId/{userId}")
    Result<List<CouponVO>> findCouponByUserId(@PathVariable Long userId, @RequestBody List<Long> categoryId);

    @PostMapping("/coupon/find-repurchase-byUserId/{userId}")
    Result<List<CouponVO>> findRepurchaseByUserId(@PathVariable Long userId, @RequestBody List<Long> categoryId);

    @PostMapping("/coupon-history/use-coupon")
    Result useCoupon(@RequestBody List<UseCouponDTO> useCouponDTOs);

    /**
     * 回退优惠卷
     * @param returnUserCouponDTO
     * @return
     */
    @PostMapping("/coupon-history/return-user-coupon")
    Result returnUserCoupon(@RequestBody ReturnUserCouponDTO returnUserCouponDTO);

    /**
     * 发放复购卷
     * @param sendRepurchaseDTO
     * @return
     */
    @PostMapping("/coupon/coupon-history/sendRepurchase")
    Result sendRepurchase(@RequestBody SendRepurchaseDTO sendRepurchaseDTO);

    /**
     * 删除复购卷
     * @param userId
     * @return
     */
    @GetMapping("/coupon/coupon-history/deleteRepurchase/{userId}")
    Result deleteRepurchase(@PathVariable Long userId);

    /**
     * 根据样品id查询绑定的复购卷
     * @return
     */
    @PostMapping("/coupon/findRepurchaseByProductIds")
    Result<Map<Long,Boolean>> findRepurchaseByProductIds(@RequestBody List<Long> ids);

    /**
     * 根据优惠卷ids查询
     * @param couponIds
     * @return
     */
    @PostMapping("/coupon/findByCouponIds")
    Result<List<CouponVO>> findByCouponIds(List<Long> couponIds);
}
